package com.drawu.drawuspring.controller;


import com.drawu.drawuspring.domain.DTO.ChatDto;
import com.drawu.drawuspring.domain.Result;
import com.drawu.drawuspring.service.IChatService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author hui
 * @since 2025-03-27
 */
@RestController
@RequestMapping("/chat")
@RequiredArgsConstructor
@Tag(name = "聊天", description = "聊天相关接口")
public class ChatController {

    private final IChatService chatService;

    @PostMapping("/chat")
    @Operation(summary = "聊天")
    public ResponseBodyEmitter chat(@RequestBody ChatDto chatDto) throws Exception {
        return chatService.chat(chatDto);
    }

    @GetMapping("/list")
    @Operation(summary = "获取聊天记录")
    public Result list() throws Exception {
        return chatService.listHistory();
    }

    @GetMapping("/delete")
    @Operation(summary = "删除聊天记录")
    public Result delete() throws Exception {
        return chatService.deleteHistory();
    }



}
